﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BGCOP.CAVTOP.BUSINESSLAYER;
using BGCOP.CAVTOP.COMMON;
using BGCOP.CAVTOP.WINFORMS.frmtlk;
using Telerik.WinControls.UI.Localization;
using Telerik.Data;
using Telerik.WinControls.UI;
using Telerik.WinControls;
using Telerik.WinControls.UI.Export; 

namespace BGCOP.CAVTOP.WINFORMS
{
    public partial class frmEmpleado : Form
    {
        public frmEmpleado()
        {
            InitializeComponent();
        }

       

        private void frmEmpleado_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'masterDBACDataSet.TTarjeta' table. You can move, or remove it, as needed.
            this.tTarjetaTableAdapter.Fill(this.masterDBACDataSet.TTarjeta);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TDivisionEmpresa' table. You can move, or remove it, as needed.
            this.tDivisionEmpresaTableAdapter.Fill(this.masterDBACDataSet.TDivisionEmpresa);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEmpresa' table. You can move, or remove it, as needed.
            this.tEmpresaTableAdapter.Fill(this.masterDBACDataSet.TEmpresa);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEstado' table. You can move, or remove it, as needed.
            this.tEstadoTableAdapter.Fill(this.masterDBACDataSet.TEstado);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TCargo' table. You can move, or remove it, as needed.
            this.tCargoTableAdapter.Fill(this.masterDBACDataSet.TCargo);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TTipoIdentificacion' table. You can move, or remove it, as needed.
            this.tTipoIdentificacionTableAdapter.Fill(this.masterDBACDataSet.TTipoIdentificacion);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEmpleado' table. You can move, or remove it, as needed.
            this.tEmpleadoTableAdapter.Fill(this.masterDBACDataSet.TEmpleado);
            RadGridLocalizationProvider.CurrentProvider = new MyEnglishRadGridLocalizationProvider();
            //foreach (var tt in radGridView1.Columns)
            //{
            //    tt.BestFit();
            //}
        }

        

        private void tEmpleadoBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Desea realizar las operaciones pendientes?", Properties.Settings.Default.Titulo,
                MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                this.Validate();
                this.tEmpleadoBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.masterDBACDataSet);
                MessageBox.Show("El registro se proceso con exito!", Properties.Settings.Default.Titulo
                                , MessageBoxButtons.OK);
            }
        }

        private void radGridView1_UserAddingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e)
        {
            //nueva fila
            //e.Rows[0].Cells["fechaUltimaGestion"].Value = DateTime.Now;
        }

        private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
        {
            e.Row.Cells["fechaUltimaGestion"].Value = DateTime.Now;
            e.Row.Cells["usuarioUltimaGestion"].Value = BGCOP.CAVTOP.WINFORMS.Program.idUsuarioActual;
        }

        private void radGridView1_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
        {
            foreach (var y in radGridView1.Rows)
            {
                y.Cells[7].Value = 2;
            }
        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Desea eliminar el registro seleccionado?", Properties.Settings.Default.Titulo,
               MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                tCargoBindingSource.RemoveCurrent();
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;

        }
    }
}
